package com.schoolET.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.schoolET.entity.WechatAndRegion;
import com.schoolET.entity.dto.WechatAndRegionDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
/**
 * <p>
 * 微信用户与区域关联表 Mapper 接口
 * </p>
 *
 * @author le
 * @since 2024-06-06
 */
@Mapper
public interface WechatAndRegionMapper extends BaseMapper<WechatAndRegion> {
    List<WechatAndRegionDTO> selectWechatRegionList(@Param(Constants.WRAPPER)QueryWrapper queryWrapper);
    WechatAndRegion checkWechatRegion(@Param("regionId") Integer regionId,@Param("openId") String openId);

    @Select("select * from wechat_and_region where wechat_id = #{wechatId} and default_location = 1")
    WechatAndRegion selectByWechatId(Integer wechatId);

    @Update("update wechat_and_region set default_location = 0 where id = #{id}")
    Integer updateDefaultLocationById(Integer id);

}
